package com.jdas.trial;

import java.io.*;

/**
 * Created by IntelliJ IDEA.
 * User: jc40819
 * Date: Sep 10, 2010
 * Time: 11:27:00 AM
 * To change this template use File | Settings | File Templates.
 */
public class TextReader {
    public static String readText(String filename)
    {
        return "This is the text string";
    }

    public static void main(String[] args)
    {
        File file = new File("no.txt");
        StringBuffer contents = new StringBuffer();
        BufferedReader reader = null;

        try
        {
            reader = new BufferedReader(new FileReader(file));
            String text = null;

            // repeat until all lines is read
            while ((text = reader.readLine()) != null)
            {
                contents.append(text)
                        .append(System.getProperty(
                                "line.separator"));
            }
        } catch (FileNotFoundException e)
        {
            e.printStackTrace();
        } catch (IOException e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                if (reader != null)
                {
                    reader.close();
                }
            } catch (IOException e)
            {
                e.printStackTrace();
            }
        }

        // show file contents here
        System.out.println(contents.toString());
    }

}
